package com.cl.park.action;

import lombok.Data;
import lombok.EqualsAndHashCode;

import com.cl.park.model.AjaxResponse;
import com.cl.park.model.Rule;
import com.cl.park.service.AdminService;
import com.opensymphony.xwork2.ActionSupport;

@Data
@EqualsAndHashCode(callSuper=false)
public class RuleSetAction extends ActionSupport {
	
	private static final long serialVersionUID = 1L;

	private AjaxResponse result;
	
	private Rule rule;
	
	private Integer id;
	
	private AdminService adminService;
	
	public String editRule(){
		if(null != id){
			rule = adminService.getRuleById(id);
		}else{
			rule = null;
		}
		id = null;
		return SUCCESS;
	}
	
	public String saveRule(){
		adminService.updateRule(rule);
		result = new AjaxResponse(true, "修改成功"); 
		return SUCCESS;
	}
	
}
